package com.teachoa.web;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

import com.alibaba.fastjson.JSON;
import com.jfinal.core.Controller;
import com.teachoa.util.Maps;

public class BaseController extends Controller {
	
	protected String success(String msg) {
		return JSON.toJSONString(Maps.newHashMap("msg", msg, "isSuccess", true));
	}
	
	protected String fail(String msg) {
		return JSON.toJSONString(Maps.newHashMap("msg", msg, "isSuccess", false));
	}
	
	protected Map<String, String> getParamMap() {
		Map<String, String[]> map = getParaMap();
		Map<String, String> newmap = new HashMap<>();
		for(Map.Entry<String, String[]> entry:map.entrySet()) {
			newmap.put(entry.getKey(), StringUtils.join(entry.getValue(), ","));
		}
		return newmap;
	}

}
